package com.app.miwawa.api.eam.service.dao;

import org.framework.common.api.service.repository.CommonRepositoryAware;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.app.miwawa.api.eam.entity.ClassesStudent;

public interface ClassesStudentDao extends CommonRepositoryAware<ClassesStudent, String> {
	
	@Modifying
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	@Query("update ClassesStudent o set o.invalid = 'T' where o.studentId = :studentid")
	public void remove(@Param("studentid") final String studentid) throws Exception;
	
	@Modifying
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	@Query("update ClassesStudent o set o.invalid = 'T' where o.studentId in (:studentids) and o.classesId in (:classesids)")
	public void remove(@Param("studentids") final String[] studentids, @Param("classesids") final String[] classesids) throws Exception;

	@Modifying
	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	@Query("update ClassesStudent o set o.classes = :classes where o.classesId = :classesid")
	public void update(@Param("classes") final String classes, @Param("classesid") final String classesid) throws Exception;
}
